//
//  InstallViewController.m
//  NewMyMusicAPP
//
//  Created by dlios on 15/6/30.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "InstallViewController.h"

@interface InstallViewController ()<UITableViewDelegate,UITableViewDataSource>

@end

@implementation InstallViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor blackColor];
    
    self.navigationController.navigationBar.translucent = NO;//取消navigationController透明度
    
    
    //       给导航栏上放自定义label
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0,  WIDTH * 100, HEIGHT * 30)];
    [view setBackgroundColor:[UIColor clearColor]];
    self.navigationItem.titleView = view;
    UILabel *title = [[UILabel alloc]initWithFrame:CGRectMake(WIDTH * 30, 0, WIDTH * 100, HEIGHT * 30)];
    title.text = @"设置";
    title.textColor = [UIColor whiteColor];
    [title setFont:[UIFont fontWithName:@"Helvetica-Bold" size:20]];//加粗字体
    [view addSubview:title];
    
    
    
    UIImage *image2 = [UIImage imageNamed:@"menu.png"];
    image2 = [image2 imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithImage:image2 style:UIBarButtonItemStylePlain target:self action:@selector(locker)];
    
    
    
    
    self.myTableView = [[[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain]autorelease];
    self.myTableView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.myTableView];
    
    self.myTableView.delegate = self;
    self.myTableView.dataSource = self;
    
    self.myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;//取消cell之间的线
    
}


-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section == 0) {
        return 1;
    }else
    {
        return 3;
    }
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *string = @"cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:string];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:string];
    }

    if (indexPath.section == 0) {
        if (indexPath.row == 0) {
            cell.textLabel.text = @"清除缓存";
        }
    }
    
    if (indexPath.section == 1) {
        if (indexPath.row == 0) {
            cell.textLabel.text = @"意见反馈";
        }
        if (indexPath.row == 1)
        {
            cell.textLabel.text = @"关于我们";
        }
        if (indexPath.row == 2)
        {
            cell.textLabel.text = @"帮助指南";
        }
    }

    cell.selectionStyle = UITableViewCellSelectionStyleNone;//取消点击效果
    return cell;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        NSUInteger size = [[SDImageCache sharedImageCache]getSize];
        CGFloat mb = size / 1024.0 / 1024.0;
        if (mb == 0) {
            UIAlertView *alerView  = [[UIAlertView alloc]initWithTitle:@"提示" message:@"您现在没有缓存,等等再来吧^ ^" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
            [alerView show];
            
        }else{
            
            NSString *string = [NSString stringWithFormat:@"您有%.2fM缓存已被清空",mb];
            UIAlertView *alerView  = [[UIAlertView alloc]initWithTitle:@"提示" message:string delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
            [alerView show];
            
            [[SDImageCache sharedImageCache] clearDisk];//清除缓存
        }

    }
    if (indexPath.section == 1) {
        if (indexPath.row == 0) {
            UIAlertView *aler = [[UIAlertView alloc] initWithTitle:@"提示" message:@"请将您的宝贵意见发送至我们的邮箱857156972@qq.com\n454691664@qq.com\n523113195@qq.com" delegate:self cancelButtonTitle:@"确认" otherButtonTitles:nil, nil];
            [aler show];
        }
        if (indexPath.row == 1) {
            helpViewController *help = [[helpViewController alloc]init];
            [self.navigationController pushViewController:help animated:YES];
            [help release];
            help.number = 1;
            
        }
        if (indexPath.row == 2) {
            helpViewController *help = [[helpViewController alloc]init];
            [self.navigationController pushViewController:help animated:YES];
            [help release];
            help.number = 2;
            
            
            
            
        }


    }
    
}

-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
    if (section == 0) {
        return @"    ";
    }
    return @"    ";
    
}


-(void)locker
{
    //抽屉
    [self.sideMenuViewController presentLeftMenuViewController];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
